home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq15.zip / GRABMAIL.SLT < prev    next >
Text File  |  1991-02-06  |  16KB  |  466 lines

  1. //-----------------------------------------------------------
  2. // GrabMail.SL?   Telix script to fetch mail from a PCBoard BBS.
  3. //
  4. // This script is normally called from the script PCBOARD.SLC.
  5. //
  6. // Please look at the comments through the whole file, and modify to
  7. // suit your needs, BEFORE you use it. Then recompile with CS GrabMail.
  8.  
  9. // Note: Lines commented out with //!! are not used in this script,
  10. // but in other, related ones. Please don't delete them; they may
  11. // become useful later.
  12. //-----------------------------------------------------------
  13.  
  14. str command [10]="Command:"  // Command prompt.
  15.    ,input   [80]             // One input line.
  16.    ,f0      [14]             // Filename for download.
  17.    ,runstr  [80]=""          // Run string for DSZ.
  18.    ,maildir [64]             // Mail directory or download directory.
  19.    ,myprot   [2]             // My protocol
  20.    ,hisprot  [2]             // PCB's protocol
  21.                              // For the Global storage:
  22.    ,global   []="GLOBAL"     // Global script.
  23.    ,bbstype  []="BTYPE"      // BBS type.
  24.    ,short    []="SHORT"      // Short BBS name.
  25.    ,Cprot    []="CPROT"      // Current protocol.
  26.    ,Hprot    []="HPROT"      // "His" protocol.
  27.    ,version  []="PCBVER"     // PCB version
  28.    ,mdir     []="MDIR"       // Mail directory.
  29.    ,prompt   []="PROMPT"     // Current command prompt.
  30.    ,dsz      []="DSZ"        // DSZ parameters.
  31.    ;     
  32.  
  33. int tol = 600                            // No activity for 1 minute
  34.    ,tmark                                // makes script time out. 
  35.    ,stat                                 // For tracking.
  36.    ,PCBver                               // PCBoard version.
  37.    ,MORE                                 // More messages
  38.    ,pcb, mbbs, rbbs, opus, fido, crcs    // different kinds of systems
  39.    ,protocol
  40.    ,usedsz                               // = 1 if using DSZ.
  41.    ,file
  42.    ;
  43.  
  44. //-----------------------------------------------------------
  45. // GrabMail script is entered here.                                   
  46. //-----------------------------------------------------------
  47.  
  48. main()
  49. {
  50. int i;
  51.  
  52. // This script is assumed to be called ONLY after logon
  53. // to perform routine tasks. This is done from the PCBoard
  54. // script, and we MUST be in the "ProDoor" door. 
  55. // The TELIX main directory must be the current one.
  56. // Therefore, system and online checks are simply skipped.
  57.  
  58.   entry();                        // Updates status bar.
  59.   newdir (_telix_dir);            // Must be in TELIX main directory!
  60.  
  61.   read (prompt,command);          // Get command prompt.
  62.   read (version,input);
  63.   PCBver = stoi (input);          // Get PCBoard version.
  64.   read (cprot,myprot);            // Get protocol.
  65.   protocol = subchr (myprot,0);   // Must be INT.
  66.  
  67.   read (hprot,hisprot);
  68.  
  69. // Check which BBS system.
  70.  
  71.   read (bbstype,input);
  72.   mbbs = pcb = rbbs = opus = fido = crcs = 0;
  73.   if      (input == "MBBS") mbbs = 1;
  74.   else if (input == "PCB" ) pcb = 1;
  75.   else if (input == "RBBS") rbbs = 1;
  76.   else if (input == "OPUS") opus = 1;
  77.   else if (input == "FIDO") fido = 1;
  78.   else if (input == "CRCS") crcs = 1;
  79.   else                                          
  80.   { wrongBBS();                    // Doesn't match script!
  81.     return (-1);
  82.   }
  83.  
  84. // ZIPM or GRAB messages.
  85. //-----------------------------------------------------------
  86.  
  87.   if (read (dsz,runstr) > 0        // Are we using DSZ?
  88.     && protocol == 'Z')
  89.   { strcat (runstr," rz -m");      // Add parameters.
  90.     usedsz = 1;
  91.   }
  92.   else                             // No.
  93.     usedsz = 0;
  94.  
  95.   MORE = 1;
  96.   while (MORE)
  97.   { f0 = "";                      // No name yet.
  98.     if (mbbs)
  99.       grab();
  100.     else if (pcb)
  101.     { if (PCBver < 145)
  102.         zipm();
  103.       else
  104.         raz();                    // PCBoard 14.5 and later
  105.     }
  106.   }
  107.   return (0);
  108. }
  109.  
  110. //-----------------------------------------------------------
  111. // This routine GRABS messages from MBBS.
  112. //-----------------------------------------------------------
  113.  
  114. grab()
  115. {
  116. str filename[]="ilename: ";              // Look for this text.
  117. int t1, t2, t3, mm;
  118.  
  119.   MORE = 0;                              // Donit. 
  120.   t1 = track ("command!", 0);            // Define new tracks.
  121.   t2 = track ("Dumping ", 0);
  122.   t3 = track ("on disk!", 0);            // Not enough space for GRAB.
  123.   mm = track ("More Messages", 0);       // More messages.
  124.   file = track (filename, 0);            // Filename comes here.
  125.  
  126.   tmark = timer_start (tol);             // Give me a minute.
  127.  
  128.   cputs ("grab^M");                      // Send a GRAB command.
  129.   while ((stat=trig()) > 0)              // answer any questions
  130.   { if (stat == t1)                      // Illegal command (line error!)
  131.       cputs ("grab^M");                  // Send a new command.
  132.  
  133.     else if (stat == t2)                 // "Dumping..."  
  134.       ;                                  // Something's happening...
  135.  
  136.     else if (stat == mm)                   // More messages next time.
  137.       MORE = 1;
  138.  
  139.     else if (stat == t3)                   // Disc is full - Can't GRAB.
  140.       return (0);                        // Return to user.
  141.  
  142.     else if (stat == file)                 // Filename expected?
  143.       break;
  144.   } 
  145.   get_file(filename);                    // Get the file.
  146. }
  147.  
  148. //-----------------------------------------------------------
  149. // This routine fetches messages from PCBoard rev. >= 14.5.
  150. //-----------------------------------------------------------
  151.  
  152. raz()
  153. {
  154. str filename[]="elected: ";              // Look for this text.
  155.  
  156. int mm                                   // More messages.
  157.    ,messages                             // Messages to fetch if == 1.
  158.    ,co         // Command
  159.    ,dot        // More coming....
  160.    ,ccm        // Compressing captured mail
  161.    ,ec1, ec2   // ENTER to continue
  162.    ;
  163.  
  164.   MORE = 0;                            // Donit. 
  165.   messages = -1;                       // Command not sent.
  166.   tol = 1200;
  167.  
  168.   do
  169.   { cputs ("t ");                        // Set protocol. Not really necessary
  170.     cputs (hisprot);                     // every time, but we can't know
  171.     cputs ("^M");                        // when it is.
  172.     waitfor (command,3);
  173.     cputs ("r a z^M");                   // Send READ ALL, then ZIP.
  174.    
  175.     co  = track (command,0);             // Back to command.
  176.     ec1 = track (")=continue?",0);       // Press ENTER.
  177.     ec2 = track ("o download?",0);       // Press ENTER.
  178.     ccm = track ("ressing capture",0);   // Compressing captured mail.
  179.     mm  = track (" limit reached)",0);   // Max. limit reached.
  180.     dot = track ("Scan",0);              // Signals that it's working.
  181.     file= track (filename,0);            // Filename comes now.
  182.  
  183.     tmark = timer_start (tol);           // Set time-out.
  184.  
  185.     while ((stat=trig()) > 0)            // answer any questions.
  186.     { if (stat == co)                    // Command?
  187.       { if (messages==1)                 // Messages?
  188.           goto fail;                     // Failure!!!
  189.  
  190.         else if (messages >= 0)          // No mail or receive
  191.           break;                         // ready.
  192.         else
  193.           goto fail;                     // Try again.
  194.       }
  195.       else if (stat==dot                 // More coming?
  196.       && messages < 0)
  197.         messages = 0;                    // Message command received.
  198.      
  199.       else if (stat == ccm)              // Compressing mail?
  200.         messages = 1;                    // Messages to fetch.
  201.  
  202.       else if (stat==ec1 || stat==ec2)   // ENTER to continue???
  203.         cputs ("^M");                    // Continue.
  204.      
  205.       else if (stat == mm)                    // More messages?
  206.         MORE = 1;
  207.  
  208.       else if (stat == file)               // Filename expected?
  209.       { messages = 1;
  210.         break;                           // Go get the mail file.
  211.       }
  212.     }
  213.     if (messages > 0)
  214.       get_file (filename);               // Get the mail file.  
  215.     break;
  216.  
  217. fail:                                    // Repeat from here if fail.
  218.     release();